package prototype;

import java.util.ArrayList;

/**
 * @author : DuJiabao
 * @Date : 2021/3/2 9:40
 * @Project : design-pattern
 * @File : null.java
 * @Desc :
 */
public class DeepClone1 implements Cloneable {
  public ArrayList arrayList;

  public DeepClone1() {
  }

  public DeepClone1(ArrayList arrayList) {
    this.arrayList = arrayList;
  }

  @Override
  protected Object clone() throws CloneNotSupportedException {
    DeepClone1 clone = (DeepClone1) super.clone();
    clone.arrayList = (ArrayList) arrayList.clone();  // 将引用数据类型也拷贝一份
    return clone;
  }
}
